﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>员工面板</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<script src="../../scripts/boot.js" type="text/javascript"></script>


<style type="text/css">
html, body {
	padding: 0;
	margin: 0;
	border: 0;
	height: 100%;
	overflow: hidden;
}
</style>
</head>
<body>

	<form id="form1" method="post">
		<!--<input name="oldid" class="mini-hidden" 不是流水号改/>-->
		<input name="oldid" class="mini-hidden" />
		<div style="padding-left: 11px; padding-bottom: 5px;">
			<table style="table-layout: fixed;">
				<tr>
					<td style="display: none; width: 80px;">"理发师编号"</td>
					<td style="display: none; width: 150px;"><input name="id"
						class="mini-textbox" required="true" emptyText="理发师编号" /></td>
					<td style="width: 80px;">理发师姓名：</td>
					<td><input name="username" class="mini-textbox"
						required="true" /></td>
					<!--<td style="width:150px;">    -->
					<!--<input name="name" class="mini-combobox" valueField="id" textField="name"-->
					<!--url="../data/AjaxService1.jsp?method=GetDepartments"-->
					<!--onvaluechanged="onDeptChanged" required="true"-->
					<!--emptyText="请选择部门"-->
					<!--/>-->
					<!--</td>-->
				</tr>
				<tr>
					<td>密码</td>
					<td><input name="password" class="mini-textbox"
						required="true" /></td>
					<td>状态：</td>
					<td>
					<select name="levelname" class="mini-radiobuttonlist">
							   
                    <option value="学徒">学徒</option>
                    <option value="中级">中级</option>
                    <option value="高级">高级</option>

					</select>
					
					</td>
				</tr>

				<tr>
					<td style="width: 80px;">性别：</td>
						<td><select name="sex" class="mini-radiobuttonlist">
								<option value="男">男</option>
								<option value="女">女</option>
						</select>
						</td>
					<td>入职时间</td>
					<td><input name="hireTime" class="mini-datepicker" showTime="true"
						required="true" emptyText="请选择日期" /></td>
					<td>电话</td>
					<td><input name="phone" class="mini-textbox"
						required="true" /> <!--<td style="width:150px;">--> <!--<input name="styleid" class="mini-combobox" valueField="id" textField="name"-->
						<!--url="../data/AjaxService.jsp?method=GetDepartments"--> <!--onvaluechanged="onDeptChanged" required="true"-->
						<!--emptyText="请选择部门"--> <!--/>--></td>
				</tr>
			</table>
		</div>

		<div style="text-align: center; padding: 10px;">
			<a class="mini-button" onclick="onOk"
				style="width: 60px; margin-right: 20px;">确定</a> <a
				class="mini-button" onclick="onCancel" style="width: 60px;">取消</a>
		</div>
	</form>
	<script type="text/javascript">
        mini.parse();


        var form = new mini.Form("form1");// new  FormData()

        // function remove() {
		//
        //     var rows = grid.getSelecteds();
        //     if (rows.length > 0) {
        //         if (confirm("确定删除选中记录？")) {
        //             var ids = [];
        //             for (var i = 0, l = rows.length; i    < l; i++) {
        //                 var r = rows[i];
        //                 console.log(r);
        //                 ids.push(r.id);
        //             }
        //             var id = ids.join(',');
        //             grid.loading("操作中，请稍后......");
        //             $.ajax({
        //                 url: "../../barberaction",
        //                 success: function (text) {
        //                     grid.reload();
        //                 },
        //                 error: function () {
        //                 }
        //             });
        //         }
        //     } else {
        //         alert("请选中一条记录");
        //     }
        // }

        function SaveData() {
            var o = form.getData();


            form.validate();
            if (form.isValid() == false) return;

            var json = mini.encode([o]);
            console.log(json)//向控制台BarberWindow.html:1 [Intervention] Slow network is detected. See https://www.chromestatus.com/feature/5636954674692096 for more details. Fallback font will be used while loading: http://localhost:8080/res/fonts/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0
          //  [{"oldid":902,"id":"902","name":"测试入职","password":"1111","levelname":"学徒","sex":"男","hireTime":"2024-04-11T18:24:39","phone":"1233211"}]

			var json2=JSON.stringify(o);
            console.log(json2)//{"oldid":902,"id":"902","name":"测试入职","password":"1111","levelname":"学徒","sex":"男","hireTime":"2024-04-11T10:24:39.000Z","phone":"1233211"}
			// console.log(data.action)
            // console.log(method)//向控制台
			if(method == "insert"){
                $.ajax({
                    url: "../../barber/insert",//增加 date 里面style 是因为         style.html 里面var style = { action: "new"};

                    contentType: 'application/json',//新
                    type: 'post',
                    data: JSON.stringify(o),


                    // data: { barber: json},旧
                    cache: false,
                    success: function (text) {
                        CloseWindow("save");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                        CloseWindow();
                    }
                });
			}else {
                $.ajax({
                    url: "../../barber/update",

                    contentType: 'application/json',//新
                    type: 'post',
                    data:JSON.stringify(o),
                    // data: { barber:json},
                    cache: false,
                    success: function (text) {
                        CloseWindow("save");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert(jqXHR.responseText);
                        CloseWindow();
                    }
                });
			}

        }

        //////////////////
       // 标准方法接口定义
        function SetData(data) {//
            console.log(data.action)
            method=data.action//insert  疑问为什么这么method全局可以用，而date.action不行

            if (data.action == "update") {

                //跨页面传递的数据对象，克隆后才可以安全使用
                data = mini.clone(data);
                var barberdata = data.barberdata
                console.log(barberdata)
                console.log(typeof barberdata)//字符串
                barberdata = JSON.parse(barberdata)
                form.setData(barberdata)


            }
        }

        function GetData() {
            var o = form.getData();
            return o;
        }
        
        
        function CloseWindow(action) {            
            if (action == "close" && form.isChanged()) {
                if (confirm("数据被修改了，是否先保存？")) {
                    return false;
                }
            }
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();            
        }
        function onOk() {
           // SetData(data);
            // console.log(date);
            SaveData();
            //UpSaveData();
            // SetData();
        }
        function onCancel(e) {
            CloseWindow("cancel");
        }
        //////////////////////////////////
        function onDeptChanged(e) {
            var deptCombo = mini.getbyName("dept_id");
            var positionCombo = mini.getbyName("position");
            var dept_id = deptCombo.getValue();

            positionCombo.load("../data/AjaxService.jsp?method=GetPositionsByDepartmenId&id=" + dept_id);
            positionCombo.setValue("");
        }



    </script>
</body>
</html>
